package com.egghiro.j2se.game.sace.state.actorstate;

import com.egghiro.framework.j2se.game.controller.action.RightAngleTrajectoryCorrection;
import com.egghiro.framework.j2se.game.controller.action.TrajectoryCorrectionAction;
import com.egghiro.framework.j2se.game.core.view.canvas.SGraphics;
import com.egghiro.framework.j2se.game.model.element.LinearVelocity2D;
import com.egghiro.j2se.game.sace.model.actor.Flyer;

public abstract class FlyerStandByState extends FlyerState {
    private static final double DEFAULT_MAX_ANGLE = 30;
    protected TrajectoryCorrectionAction aimCorrection;

    public FlyerStandByState(Flyer flyer, double speed, double angle) {
        this(flyer, new LinearVelocity2D(speed, angle));
    }

    public FlyerStandByState(Flyer flyer, LinearVelocity2D speed) {
        super(flyer, speed);
        this.aimCorrection = new RightAngleTrajectoryCorrection(flyer, DEFAULT_MAX_ANGLE);
    }

    @Override
    public void act() {
        aimCorrection.trajectoryCorrrection(getFlyer().getTarget(), this.speed);
    }

    @Override
    public void render(SGraphics g) {
        getFlyer().renderGeneral(g);
    }
}
